<template>
  <div>
    <el-dialog
      :visible.sync="showDialog"
      append-to-body
      destroy-on-close= true
      :close-on-click-modal="false"
      @close="close"
      width="40%"
    >
      <div class="showbox">
        <div :style="this.showoff">
          <h3>承运商报价</h3>
          <el-form
            :model="Form"
            ref="Form"
            label-width="100px"
            class="demo-ruleForm"
            disabled
          >
            <el-form-item label="≤1吨">
              <el-input v-model="Form.quotedPrice1"></el-input>
            </el-form-item>
            <el-form-item label="≤3吨">
              <el-input v-model="Form.quotedPrice2"></el-input>
            </el-form-item>
            <el-form-item label="≤5吨">
              <el-input v-model="Form.quotedPrice3"></el-input>
            </el-form-item>
            <el-form-item label="≤10吨">
              <el-input v-model="Form.quotedPrice4"></el-input>
            </el-form-item>
            <el-form-item label="≤15吨">
              <el-input v-model="Form.quotedPrice5"></el-input>
            </el-form-item>
            <el-form-item label="≤20吨">
              <el-input v-model="Form.quotedPrice6"></el-input>
            </el-form-item>
            <el-form-item label="≤25吨">
              <el-input v-model="Form.quotedPrice7"></el-input>
            </el-form-item>
            <el-form-item label="≤30吨">
              <el-input v-model="Form.quotedPrice8"></el-input>
            </el-form-item>
          </el-form>
        </div>
        <div style="width: 60%">
          <h3>调整报价</h3>
          <el-form
            :model="ruleForm"
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-form-item label="≤1吨" prop="quotedPrice1">
              <el-input v-model.number="ruleForm.quotedPrice1"></el-input>
            </el-form-item>
            <el-form-item label="≤3吨" prop="quotedPrice2">
              <el-input v-model.number="ruleForm.quotedPrice2"></el-input>
            </el-form-item>
            <el-form-item label="≤5吨" prop="quotedPrice3">
              <el-input v-model.number="ruleForm.quotedPrice3"></el-input>
            </el-form-item>
            <el-form-item label="≤10吨" prop="quotedPrice4">
              <el-input v-model.number="ruleForm.quotedPrice4"></el-input>
            </el-form-item>
            <el-form-item label="≤15吨" prop="quotedPrice5">
              <el-input v-model.number="ruleForm.quotedPrice5"></el-input>
            </el-form-item>
            <el-form-item label="≤20吨" prop="quotedPrice6">
              <el-input v-model.number="ruleForm.quotedPrice6"></el-input>
            </el-form-item>
            <el-form-item label="≤25吨" prop="quotedPrice7">
              <el-input v-model.number="ruleForm.quotedPrice7"></el-input>
            </el-form-item>
            <el-form-item label="≤30吨" prop="quotedPrice8">
              <el-input v-model.number="ruleForm.quotedPrice8"></el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <el-form ref="descForm" :model="form" label-width="80px">
        <el-form-item label="备注">
          <el-input type="textarea" v-model="descForm.desc"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="close()">取消</el-button>
        <el-button @click="submit('ruleForm')" type="primary">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { deepClone } from "@/util/util.js";
export default {
  name: "bulkmodifyQuotation",
  props: {
    modifyData: {},
    identity: {},
  },
  data() {
    return {
      showDialog: false,
      callback: () => {},
      form: {},
      showoff: {},
      transmission: {},
      descForm:{
        desc:""
      },
      ruleForm: {
        quotedPrice1: "",
        quotedPrice2: "",
        quotedPrice3: "",
        quotedPrice4: "",
        quotedPrice5: "",
        quotedPrice6: "",
        quotedPrice7: "",
        quotedPrice8: "",
        desc: "",
      },
      Form: {
        quotedPrice1: "",
        quotedPrice2: "",
        quotedPrice3: "",
        quotedPrice4: "",
        quotedPrice5: "",
        quotedPrice6: "",
        quotedPrice7: "",
        quotedPrice8: "",
      },
      rules: {
        quotedPrice1: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice2: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice3: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice4: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice5: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice6: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice7: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
        quotedPrice8: [
          { required: true, message: "请输入报价", trigger: "blur" },
          { type: "number", message: "必须为数字值" },
        ],
      },
    };
  },
  watch: {
    modifyData() {
      this.transmission = this.modifyData;
      this.Form = { ...this.modifyData };
      this.isManagement = this.identity.isManagement;
      this.showoff = this.identity.showoff;
    },
  },
  methods: {
    open(row, { callback }) {
      this.callback = callback;
      this.showDialog = true;
    },
    close() {
      this.showDialog = false;
      this.Form = { ...this.modifyData };
      this.ruleForm = {
        quotedPrice1: "",
        quotedPrice2: "",
        quotedPrice3: "",
        quotedPrice4: "",
        quotedPrice5: "",
        quotedPrice6: "",
        quotedPrice7: "",
        quotedPrice8: "",
        desc: "",
      };
    },

    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let inquiryId = {
            ...this.transmission,
            ...this.ruleForm,
            ...this.descForm
          };
          this.callback(deepClone(inquiryId));
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style>
.showbox {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
}
</style>
